-
-
Notifications
You must be signed in to change notification settings - Fork 149
CYF London | Fatma Arslantas | Module-Data-Groups | Week 2 #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) { | ||
return false; | ||
} | ||
// 〰️ Using hasOwnProperty to check if the key exists directly on the object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job verifying the object parameter types in the contains function, and you've successfully met all the task requirements!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback! I’m glad to hear that. Let me know if there’s anything else I can improve. 🤗
// 〰️ Example: 'John%20Doe' -> 'John Doe', '5%25' -> '5%' | ||
// 〰️ rawKey || "" ensures that if rawKey is undefined, null, or empty, it returns to an empty string. | ||
const key = decodeURIComponent(rawKey || ""); | ||
const value = decodeURIComponent(rawValue.join("=") || ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you demonstrates a solid understanding of value-key pair parsing. Maybe in order to enhance test cases, you can also add dublicate test case for keys i.e "key=value1&key=value2"
something like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback @halilibrahimcelik!
I've updated the implementation to handle duplicate keys by storing their values in an array. Additionally, I’ve added a test case to validate this behavior, ensuring that query strings like key=value1&key=value2 are correctly parsed into { key: ["value1", "value2"] }. I hadn’t considered this, but your suggestion helped improve my code. Thanks again!
Let me know if there’s anything else I can improve. 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad to hear that! It’s a niche case, and in a real-world scenario, it’s unlikely to have two different values with the same key. However, it’s a good challenge, keep up the good work! Cheers 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 🤗
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.